package cn.edu.hqu.tkserver.modules.tk.api;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.edu.hqu.tkserver.common.utils.R;
import cn.edu.hqu.tkserver.modules.tk.entity.OrderEntity;
import cn.edu.hqu.tkserver.modules.tk.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/api/order/")
public class ApiOrderController {
	
	@Autowired
	private OrderService orderService;
	
	@AuthIgnore
	@GetMapping("list")
    public R list(@RequestParam Map<String, Object> params) {
		List<OrderEntity> orderList = orderService.queryList(params);
    	return R.ok().put("orderList", orderList);
    }
	
	@AuthIgnore
    @PostMapping("save")
    public R save(@RequestBody OrderEntity order) {
    	order.setCreateTime(new Date());
    	orderService.save(order);;
    	return R.ok();
    }
}
